<?php
/**
 * 删除页面
 * @author LeoNing
 *
 */
class DelPage extends Action {
	/*
	 * (non-PHPdoc) @see Action::execute()
	 */
	public function execute($params) {
		$me = check_login ( ADMIN_LOGIN_PAGE );
		$ids = rqst ( 'pid' );
		$ids = safe_ids ( $ids, ",", true );
		
		if (! empty ( $ids )) {
			$pageM = new WebPageModel ();
			$pageM->begin ();
			$msg = apply_filter ( 'on_delete_page', true, $ids );
			$rst = false;
			if ($msg === true) {
				$rst = $pageM->delete ( array ('page_id IN' => $ids ) );
			}
			if ($rst !== false) { // 删除标签
				$tagM = new WebPageTagModel ();
				$rst = $tagM->delete ( array ('page_id IN' => $ids ) );
			}
			if ($rst !== false) {
				$pageM->commit ();
			} else {
				$pageM->rollback ();
				sess_add ( 'page_tip_info', '出错了:' . $pageM->last_error_msg () . '<br/>' . $msg );
			}
		} else {
			sess_add ( 'page_tip_info', '出错了,无效的网页编号.' );
		}
		Response::redirect ( $this->referer );
	}
}